package com.kangtu.demofilter01.filter;

import javax.servlet.*;
import java.io.IOException;

/**
 * @program: demo-weix-pay
 * @description: LogCostFilter
 * @author: 亮子说编程
 * @create: 2021-03-08 17:35
 **/
public class LogCostFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void destroy() {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println(servletRequest.getRemoteAddr()+"="+(System.currentTimeMillis()-start));
    }
}
